#include "SimpleVector2D.h"

using namespace SimpleVector2D;

void Vector2D::set(float a_floatX, float a_floatY){
	x = a_floatX;
	y = a_floatY;
};

void Vector2D::add(Vector2D a_Vector2D){
	x += a_Vector2D.x;
	y += a_Vector2D.y;
};

Vector2D Vector2D::plus(Vector2D a_Vector2D){
	Vector2D t_Vector2D;
	t_Vector2D.set(x, y);
	t_Vector2D.x += a_Vector2D.x;
	t_Vector2D.y += a_Vector2D.y;
	return t_Vector2D;
};

void Vector2D::subtract(Vector2D a_Vector2D){
	x -= a_Vector2D.x;
	y -= a_Vector2D.y;
};

Vector2D Vector2D::minus(Vector2D a_Vector2D){
	Vector2D t_Vector2D;
	t_Vector2D.set(x, y);
	t_Vector2D.x -= a_Vector2D.x;
	t_Vector2D.y -= a_Vector2D.y;
	return t_Vector2D;
};

void Vector2D::multiply(float a_number){
	x *= a_number;
	y *= a_number;
};

Vector2D Vector2D::product(float a_number){
	Vector2D t_Vector2D;
	t_Vector2D.set(x, y);
	t_Vector2D.x *= a_number;
	t_Vector2D.y *= a_number;
	return t_Vector2D;
};

void Vector2D::divide(float a_number){
	x /= a_number;
	y /= a_number;
};

Vector2D Vector2D::quotient(float a_number){
	Vector2D t_Vector2D;
	t_Vector2D.set(x, y);
	t_Vector2D.x /= a_number;
	t_Vector2D.y /= a_number;
	return t_Vector2D;
};

float Vector2D::magnitude(){
	return sqrt(x*x+y*y);
};

float Vector2D::magnitudeSquare(){
	return (x*x+y*y);
};

void Vector2D::normal(){
	float t_magnitude = magnitude();
	if(t_magnitude > 0){
		x /= t_magnitude;
		y /= t_magnitude;
	}
};

Vector2D Vector2D::normalize(){
	Vector2D t_normal;
	t_normal.set(x, y);
	float t_magnitude = t_normal.magnitude();
	if(t_magnitude > 0){
		t_normal.x /= t_magnitude;
		t_normal.y /= t_magnitude;
	}
	return t_normal;
};

float Vector2D::dotProduct(Vector2D a_Vector2D){
	return float(x * a_Vector2D.x + y * a_Vector2D.y);
};